package com.syn.vr.activity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import androidx.appcompat.app.AppCompatActivity;

import com.gaoyi.basemodule.baseUtil.DateFormatUtil;
import com.syn.vr.cic.CicConfiguration;
import com.syn.vr.constant.BundleKeyName;
import com.syn.vr.util.FileUtil;

import java.util.Date;

public class JumpActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // 刷卡间隔时间短时，不允许操作，避免恶意频繁刷卡
        if (!CicConfiguration.getInstance().canOpen()) {
            finish();
            return;
        }
        CicConfiguration.getInstance().setLastTime();
        String cardNo = getIntent().getStringExtra(BundleKeyName.CARD_NO);
        Log.i("TAG", "JumpActivity: " + cardNo);
        String time = DateFormatUtil.DateTimeToStr(new Date(), "yyyy-MM-dd HH:mm:ss");
        FileUtil.writeLog(this, "SwipeCardLog", cardNo + "," + time + System.lineSeparator());
        jumpWithCardNo(MainActivity.class, cardNo);
        finish();
    }

    private void jumpWithCardNo(Class<?> cls, String cardNo) {
        Intent intent1 = new Intent(getApplicationContext(), cls);
        Log.i("TAG", "jumpWithCardNo: " + cardNo);
        intent1.putExtra(BundleKeyName.CARD_NO, cardNo);
        getApplication().startActivity(intent1);
    }
}